package com.cin.cma.common.enums;


import com.cin.cma.common.exception.UserFriendlyException;
import lombok.Getter;


public enum InterfaceChannelEnum {

    /**
     * 电影云
     */
    DIAN_YING_YUN("DIAN_YING_YUN", "电影云"),
    /**
     * 云智
     */
    YUN_ZHI("YUN_ZHI", "云智"),
    /**
     * 云智Pro
     */
    YUN_ZHI_PRO("YUN_ZHI_PRO", "云智Pro"),
    /**
     * 鼎新
     */
    DING_XIN("DING_XIN", "鼎新"),
    /**
     * 火烈鸟
     */
    FMG("FMG", "火烈鸟"),
    /**
     * 1905
     */
    ONZF1905("ONZF1905", "1905"),
    /**
     * 辰星
     */
    TSP("TSP", "辰星"),
    /**
     * 辰星4.0
     */
    TSP_FOUR("TSP_FOUR", "辰星4.0"),
    /**
     * VISTA
     */
    VISTA("VISTA", "VISTA"),
    /**
     * 佳影本地
     */
    FINIXX("FINIXX", "佳影本地"),
    /**
     * 文鱼电影（第三方：包含猫眼，淘票票）
     */
    WEN_YU("WEN_YU", "文鱼");


    @Getter
    private final String code;
    @Getter
    private final String description;

    InterfaceChannelEnum(String code, String description) {
        this.description = description;
        this.code = code;
    }

    /**
     * 根据CODE获取枚举实体
     *
     * @param code code
     * @return InterfaceChannelEnum
     * @throws UserFriendlyException 异常
     */
    public static InterfaceChannelEnum get(String code) throws UserFriendlyException {
        for (InterfaceChannelEnum channelEnum : InterfaceChannelEnum.values()) {
            if (channelEnum.code.equals(code)) {
                return channelEnum;
            }
        }
        throw new UserFriendlyException(SystemErrorCode.SYSTEM_ERROR, "渠道不存在：" + code);
    }
}

